import java.util.Scanner;
import java.lang.String;

/**
   A program reads in a string, followed by an integer n,
   where the value of the integer should be smaller than the
   length of the string.  The program then prints out the last
   n characters of the string.
*/
public class Strings
{
   public static void main (String[] args)
   {
      // Display prompt for string of characters
      System.out.println("Please enter a string: ");

      // Read string
      Scanner in = new Scanner(System.in);
      String str = in.nextLine();

      // Display prompt for integer n
      System.out.println("Please enter a value for n: ");

      // Read n
      int n = in.nextInt();

      String subStr = new String();
      subStr = str.substring(str.length()-n);
      System.out.println(subStr);

   }
}